package com.hisense.ovcloud.apicontrol.tool;

import com.hisense.ovcloud.apicontrol.config.Constants;
import org.apache.commons.lang3.StringUtils;

import java.util.stream.Stream;

public class PathUtils {
    public static boolean ifInEndPoints(String uri, String endPoints) {
        return StringUtils.isEmpty(endPoints) && !endPoints.contains(Constants.SecurityParamters.SPLITOR)
                || endPoints.contains(Constants.SecurityParamters.SPLITOR)
                && Stream.of(endPoints.split(Constants.SecurityParamters.SPLITOR)).anyMatch(uri::equalsIgnoreCase);
    }
    public static boolean startsWithEndPoints(String uri, String endPoints) {
        return StringUtils.isEmpty(endPoints) && !endPoints.contains(Constants.SecurityParamters.SPLITOR)
                || endPoints.contains(Constants.SecurityParamters.SPLITOR)
                && Stream.of(endPoints.split(Constants.SecurityParamters.SPLITOR)).anyMatch(uri::startsWith);
    }
}
